/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.mobiubiq.directory.client.object;

import javax.microedition.location.Coordinates;
import javax.microedition.location.Location;

/**
 *
 * @author Marnix Renne
 */
public class LocationObject extends AbstractObject {
    private double longitude;
    private double latitude;
    
    public LocationObject() {
        super("", ObjectType.BARCODE);
    }
    public LocationObject(Coordinates coordinates) {
        super(String.valueOf(coordinates.hashCode()), ObjectType.LOCATION);
        latitude = coordinates.getLatitude();
        longitude = coordinates.getLongitude();
        
    }
    public LocationObject(Location location) {
        this(location.getQualifiedCoordinates());
    }
    
    public double getLongitude() {
        return longitude;
    }
    
    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public int hashCode() {
        int hash = 7;
        hash = 41 * hash + (int) (Double.doubleToLongBits(this.longitude) ^ (Double.doubleToLongBits(this.longitude) >>> 32));
        hash = 41 * hash + (int) (Double.doubleToLongBits(this.latitude) ^ (Double.doubleToLongBits(this.latitude) >>> 32));
        return hash;
    }
    
    public boolean equals(Object o) {
        if(this == o) {
            return true;
        }
        if(o instanceof LocationObject) {
            LocationObject other = (LocationObject) o;
            if(getType() == other.getType()) {
                if(getLatitude() == other.getLatitude()) {
                    if(getLongitude() == other.getLongitude()) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
}
